<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>委外催收-资料</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper" style="overflow: hidden">
    <div class="fieldset1 tabel_col clearFix">
        <form id="uploadCltAuthFileForm">
            <%--上传附件--%>
            <div class="fieldBox col_100" id="uploadDiv" style="display: none;">
                <div class="label">上传</div>
                <div class="field">
                    <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true">
                        <jsp:param name="filePath" value="cltAuth"/>
                    </jsp:include>
                    <input name="pkId" id="pkId" type="hidden" value="${pkId }">
                </div>
            </div>
        </form>
        <%--附件显示--%>
        <div class="fieldBox col_100">
            <div class="label">附件</div>
            <div class="field">
                <jsp:include page="../../system/sysUlFilesRec/sysUlFileRecListDetail.jsp" flush="true">
                    <jsp:param name="tabNm" value="RSK_CLT_AUTH_RCV_APL"/>
                    <jsp:param name="pkId" value="${pkId}"/>
                </jsp:include>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    var basePath = '<%=path%>';
    var edit = '${edit}';
    var pkId = '${pkId }';
    $(function () {
        // 文件列表grid
        var fileGrid = liger.get("ligergrid1");
        if (edit == '1') {
            $("#uploadCltAuthFileForm").ligerForm({
                validate: true
            });
            $("#uploadDiv").show();
        }

        resetGridColumn();

        frameElement.dialog.onOk = function () {
            var form = liger.get("uploadCltAuthFileForm");
            var fileParams = getUploadResultParams();//获取附件上传的信息
            if (fileParams.length == 0) {
                $.ligerDialog.SQalert({content: "请上传附件！", SQ_type: "error"});
                return;
            }
            $.ligerDialog.confirm("确定保存资料吗？", function (flag) {
                if (flag == false) return;
                var formData = form.getData();
                formData.pkId = pkId;
                formData.fileParams = JSON.stringify(fileParams);

                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: formData,
                    url: basePath + '/clt/auth/file/uploadCltAuthFile.do',
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({
                                content: msg.info, SQ_showButtons: true, SQ_type: "success", onClose: function () {
                                    //frameElement.dialog.close();
                                    fileGrid.reload();
                                }
                            });
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_showButtons: true, SQ_type: "error"});
                        }
                    }
                });
            });
        }
    });

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value && value != '') {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    // 重置文件列表column
    function resetGridColumn() {
        var columns = [
            {display: '<div class="headCellWrap">文件名<span class="sq-button-hasicon" title="打包下载" onclick="downloadFileByUrl();"><i class="sqBtnIco_8"></i></span></div>', minWidth: 100,
                render: function (rowdata, rowindex, value) {
                    var h = '<a href="javascript:uploadFileByUrl(';
                    h += "'" + rowdata.filePath + "'";
                    h += ",'" + rowdata.fileNm + "'";
                    h += ')">' + rowdata.fileNm + '</a>';
                    return h;
                }
            },
            {display: '上传时间', width: 160, name: 'crtTm', render: renderDate},
        ];
        if (edit == '1') {
            columns.push({
                display: '操作', isSort: false, width: 60,
                render: function (rowdata, rowindex, value) {
                    var h = '<a class="sq-button-hasicon" href="javascript:uploadFileDeleteRow(';
                    h += "'" + rowdata.id + "'";
                    h += ",'ligergrid_bankacc'"
                    h += ')"><i class="sqBtnIco_7"></i>删除</a>'
                    return h;
                }
            });
        }
        fileGrid.set('columns', columns);
    }
</script>

</body>
</html>

